#include <stdio.h>
#include <math.h>
#include <stdlib.h>

double xpoint(double x1, double x2);
double func(double x);
double root(double x1, double x2);

int main()
{
    double x1, x2, x;
    x1 = 0;
    x2 = 10;
    x = root(x1, x2);
    printf("x:%lf\n",x);
    return 0;
}

double func(double x)
{
    double re;
    re = pow(x,3) - 5*pow(x,2) + 16*x - 81;
    return re;
}

double xpoint(double x1, double x2)
{
    return (x1*func(x2)-x2*func(x1))/(func(x2)-func(x1));
}

double root(double x1, double x2)
{
    double x = x1;
    while (func(x) > 0.1 || func(x)<-0.1)
    {
        x = xpoint(x, x2);
        //printf("%lf\n", x);
    }
    return x;
}